/*
    This file is part of Epoch <http://code.google.com/p/epoch/>.

    Copyright (C) 2011 Adam Meily <meily.adam@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/


#ifndef REVISION_H
#define REVISION_H
#include <QtCore/QDateTime>
#include "Backup.h"
#include "Share.h"
#include "Model.h"
#include <Message.h>

class Revision : public Model
{
public:
    Revision();
    Revision(int id, const QByteArray& uuid, const Share& share, quint64 size,
             const QDateTime& lastSeen, const QDateTime& backupTime,
             const QString& path, int revision);
    
    Revision(const Revision& other);
    virtual ~Revision();
    virtual Revision& operator=(const Revision& other);
    
    const QDateTime& lastSeen() const;
    const QDateTime& backupTime() const;
    const QString& path() const;
    //QString name() const;
    const QByteArray& uuid() const;
    const Share& share() const;
    int reivision() const;
    quint64 size() const;
    //const Backup& backup() const;
    const Revision& basis() const;
    Revision inc() const;
    
    void updateLastSeen();
    void setBackupTime();
    
    static QByteArray clacUuid(const Share& share, const QString& path);
    
    static Revision fromRecord(const Record& record, const Share& share,
                               const Backup& backup, const QString& path,
                               bool& ok);
    
    bool isNull() const;
    bool isSameRevision(const Record& record) const;
    void inject(const Revision& basis);
    void inject(const Share& share);
    
private:
    QString m_path;
    //QString m_name;
    QByteArray m_uuid;
    int m_revision;
    quint64 m_size;
    QDateTime m_lastSeen;
    QDateTime m_backupTime;
    Share m_share;
    Revision m_basis;
    //Backup m_backup;
};

#endif // REVISION_H
